#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<unordered_map>
#include<queue>
#include<stack>
#include <functional>
#include <memory>
using namespace std;

class Solution {
public:
    int maxSubarraySumCircular(vector<int>& nums) {
        int n = nums.size();
        vector<int> f(n);
        auto g = f;
        f[0] = nums[0];
        g[0] = nums[0];
        int maxi = nums[0];
        int mini = nums[0];
        int sum = 0;
        sum += nums[0];
        for (int i = 1; i < n; i++)
        {
            sum += nums[i];
            f[i] = max(nums[i], f[i - 1] + nums[i]);
            maxi = max(maxi, f[i]);
            g[i] = min(nums[i], nums[i] + g[i - 1]);
            mini = min(mini, g[i]);
        }
        return sum == mini ? maxi : max(sum - mini, maxi);
    }
};

int main()
{
    vector<int> in(30, -1);
	return 0;
}